Fix codegen crash on list text segments and support latest Figma API - #49
Merged
Conversation
Figma returns listOptions as undefined for the non-list segments of a TEXT node that also contains a bulleted list, so reading .type threw and the whole codegen rejected. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
The bundle is minified, so Figma stack traces are unreadable. Tag errors with the node being processed and format a copyable report instead. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Tag buildTree, addComponentTree, renderTree, renderText and every prop getter so a failure names the exact node and getter. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
A throw surfaced only as an unhandled promise rejection. Catch it and return the diagnostic report as a PLAINTEXT block users can copy. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Figma added SPACE_EVENLY and SPACE_AROUND to primaryAxisAlignItems; map them to the matching justify-content values instead of dropping the prop. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
VariableValue gained MotionEasing with the Motion API, so figma.util.rgba no longer accepts it. Narrow it out alongside the existing boolean/number guard. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Every codegen cache is keyed by node.id, so the reset list must stay complete. Move it into one function instead of an inline block only code-impl knows about. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
beforeEach reset only 5 of the 12 codegen caches, so ids reused across test files (status-error in check-asset-node.test.ts, status-success in codegen.test.ts) leaked a stale sameColor and broke variant merging depending on file order. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Codegen crashed in Dev Mode with an unhandled promise rejection:
The bundle is minified, so the stack trace was unusable and the panel showed nothing at all.
Root cause
renderTextreadseg.listOptions.typeunconditionally. Figma returnslistOptionsasundefined— not{ type: 'NONE' }— for the non-list segments of a TEXT node thatalso contains a bulleted or numbered list:
Changes
Fix crash on list text segments — a missing
listOptionsnow means "not a list".Add codegen diagnostics (
codegen/utils/diagnostics.ts) — instead of relying on minifiedstack traces, each codegen step tags the error it observes with the node it was processing.
Tagging is zero-cost on the success path; nothing is formatted until an error escapes.
Trace codegen steps —
buildTree,addComponentTree,renderTree,renderTextand everyprop getter are tagged, so a failure names the exact node and the exact getter.
Report codegen errors in code panel — the
generatehandler now catches, logs, and returnsthe report as a
PLAINTEXTblock, so a crash produces something copy-pasteable instead of asilent rejection:
That report is what identified this bug.
Dependency update
typescript@7,@figma/plugin-typings@1.137,@rspack/*@2.2,@biomejs/biome@2.5,@types/bun@1.4. Two API unions widened and broketsc --noEmit; both are fixed by supportingthe new values rather than pinning back:
Support new auto layout distributions —
primaryAxisAlignItemsgainedSPACE_EVENLYandSPACE_AROUND. They are now mapped tojustify-content: space-evenly/space-around.Previously these frames silently lost their
justifyContentprop entirely.Exclude motion easing from color variables —
VariableValuegainedMotionEasing, whichfigma.util.rgba()does not accept. A COLOR variable can never resolve to one at runtime, so itis narrowed out via a new
isMotionEasingguard folded into the existingboolean/numbercheck — no new runtime branch, no
as any.Verification
(
TypeError: undefined is not an object (evaluating 'seg.listOptions.type'),at map), thenpassing after the fix.
bun run test(tsc --noEmit && bun test --coverage) — 1005 pass / 0 fail, 268 snapshotsunchanged, coverage threshold (100%) held.
biome check --error-on-warningsclean,rspack buildsucceeds on the new toolchain.dist/code.jswas driven the same way Figma drives it, with the reported node shape(segment
[0]listOptions: undefined+ segment[1]UNORDERED): codegen now succeeds andemits
<Text as="ul"> ... <li>.Ultraworked with Sisyphus